import req from "../utils/http.js"


//获取新闻分类列表
export function getCategorylistings() {
    return req.post(`/api/cms/category/open/list`)
}

//获取各类新闻列表
export function getNewsList(pageNum = 1, pageSize = 1, categoryId = 10) {
    // let parms= `{"pageNum":1,"pageSize":1}`
    let parms = new URLSearchParams()
    parms.append("pageNum", pageNum)
    parms.append("pageSize", pageSize)
    parms.append("categoryId", categoryId)
    return req.post(`/api/cms/article/open/hot/list`, parms)
}

//获取新闻详情
export function getDetailsNews(articleId) {
    return req.get(`/api/cms/article/open/detail/${articleId}`)
}

//获取热搜列表
export function getHotList(pageNum = 1, pageSize = 1) {
    // let parms= `{"pageNum":1,"pageSize":1}`
    let parms = new URLSearchParams()
    parms.append("pageNum", pageNum)
    parms.append("pageSize", pageSize)
    return req.post(`/api/cms/article/open/hot/list`, parms)
}

//注册账号
export function getRegisterAccount(loginName, userName, phonenumber, code, password, sex, remark) {
    // let parms= `{"pageNum":1,"pageSize":1}`
    let parms = new URLSearchParams()
    parms.append("loginName", loginName)
    parms.append("code", code)
    parms.append("phonenumber", phonenumber)
    parms.append("password", password)
    parms.append("userName", userName)
    parms.append("sex", sex)
    parms.append("remark", remark)
    return req.post(`/api/registry`, parms)
}

//获取验证码
export function getMobile(mobile) {
    return req.get(`/api/short-message/vcode/${mobile}`)
}

//登陆
export function getLogin(username, rememberMe, password) {
    let parms = new URLSearchParams()
    parms.append("username", username)
    parms.append("password", password)
    parms.append("rememberMe", rememberMe)
    return req.post(`/api/login`, parms)
}

//收藏新闻
export function getCollectTheNews(articleId) {
    return req.get(`/api/cms/collect/collect/article/${articleId}`)
}

//收藏新闻列表
export function getCollectTheNewsList() {
    return req.get(`/api/cms/article/collect/list`)
}

//点赞
export function getGiveLike(articleId) {
    return req.get(`/api/cms/article/add/zan/${articleId}`)
}

//忘记密码
export function getForgetThePassword(loginName, password, phonenumber, code) {
    // let parms= `{"pageNum":1,"pageSize":1}`
    let parms = new URLSearchParams()
    parms.append("loginName", loginName)
    parms.append("code", code)
    parms.append("phonenumber", phonenumber)
    parms.append("password", password)
    return req.post(`/api/password/forget`, parms)
}

// //订阅新闻
// export function getSubscriptionNews(categoryIds) {
//     // let parms= `{"pageNum":1,"pageSize":1}`
//     let parms= new URLSearchParams()
//     parms.append("categoryIds",categoryIds)
//     return req.post(`/api/cms/userCategory/subscription/category`,parms)
// }
// //订阅列表
// export function getSubscriptionList() {
//     return req.get(`/api/cms/category/subscription/list`)
// }
//个人信息
export function getMyInformation() {
    return req.get(`/api/login-user/info`)
}



